package com.hbnu.tangyalu;

import java.util.Scanner;

public class BankAccount {
    //账号
    private String accountNumber;
//    余额
    private double balance;
    Scanner scanner=new Scanner(System.in);

    //存款
    public void deposit(){
        System.out.println("请你输入你的账户：");
        String scaccount=scanner.next();
        System.out.println("请你输入你要存款金额：");
        double money=scanner.nextDouble();
        if (scaccount.equals(accountNumber)){
            balance=balance+money;
        }
        else {
            System.out.println("输入账户错误");
        }
    }
//    取款
    public void withdraw(){
        System.out.println("请你输入你的账户：");
        String scaccount=scanner.next();
        System.out.println("请你输入你要取款金额：");
        double money=scanner.nextDouble();
        if (scaccount.equals(accountNumber)){
            if (money<balance){
                System.out.println("您的余额不足，无法取款");
            }
            else{
                balance=balance -money;
            }
        }
        else {
            System.out.println("输入账户错误");
        }

    }
//    查看余额
    public void getBalance(){
        System.out.println("请你输入你的账户：");
        String scaccount=scanner.next();
        if (accountNumber.equals(scaccount)){
            System.out.println("你的余额为："+balance);
        }
    }
    public class SavingsAccount{
        //利率
        private double interestRate;
//        计算利息
        public void calculateInterest(){
            double interest=balance*interestRate;
            System.out.println("您的存款利息为："+interest);
        }

    }
}

